﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Texfina.BOQry.Co;
using Texfina.Core.Common;
using Texfina.Entity.Co;

namespace CO
{
    public partial class wfProductoBnd_ : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                ListarProducto();
                btnNuevo.ImageUrl = Constants2.ConstMenuControlValue.BUTTON_NEW;

            }
        }
        private void ListarProducto()
        {
            try
            {
                EProducto prod = new EProducto();

                prod.Id_producto = txtcodigo.Text;

                prod.Ds_producto = txtDescripcion.Text;
                prod.IdEmpresa = Session[ConstSessionVar.EMPRESA].ToString();

                gvList.DataSource = BProducto.GetListFill_(prod);

                gvList.DataBind();
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            ListarProducto ();
           
        }

        protected void btnNuevo_Click(object sender, ImageClickEventArgs e)
        {
            Session["htaOProducto"] = null;
            Hashtable HtaDatos = new Hashtable();
            Session["htaOProductoNuevo"] = HtaDatos;
            Response.Redirect("wfProductoMnt.aspx");
        }

        protected void gvList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "Detalle":
                    string Id_producto = (string)e.CommandArgument;
                    Hashtable htDatos = new Hashtable();
                    htDatos.Add("Id_producto", Id_producto);
                    htDatos.Add("in_ventana", "1");
                    Session["htaOProducto"] = htDatos;
                    Response.Redirect("wfProductoMnt.aspx");
                    break;
 
            }
        }
    }
}